package cn.ibizlab.odoo.core.odoo_mail.service.impl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.util.Collection;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import cn.ibizlab.odoo.core.client.model.Imail_channel;
import cn.ibizlab.odoo.core.odoo_mail.domain.Mail_channel;
import cn.ibizlab.odoo.core.odoo_mail.filter.Mail_channelSearchContext;
import cn.ibizlab.odoo.core.odoo_mail.service.IMail_channelService;
import cn.ibizlab.odoo.util.SearchResult;
import cn.ibizlab.odoo.util.log.IBIZLog;

/**
 * 实体[讨论频道] 服务对象接口实现
 */
@Slf4j
@IBIZLog
@Service
public class Mail_channelServiceImpl implements IMail_channelService {

    @Autowired
    private cn.ibizlab.odoo.core.client.service.Imail_channelClientService mail_channelClientService;

    @Override
    public void removeBatch(Collection<? extends Serializable> idList, int batchSize) {

        //mail_channelClientService.removeBatch(mail_channels) ;

    }

    @Override
    public boolean update(Mail_channel mail_channel) {
        boolean bOk = false ;
        Imail_channel clientModel = this.convert2Model(mail_channel,null);
        mail_channelClientService.update(clientModel) ;
        this.convert2Domain(clientModel,mail_channel) ;
        bOk = true;
        return bOk ;
    }

    @Override
    public boolean remove(Integer id) {
        boolean bOk = false ;
        Imail_channel clientModel = mail_channelClientService.createModel();
        clientModel.setId(id);
        mail_channelClientService.remove(clientModel) ;
        bOk = true ;
        return bOk ;
    }

    @Override
    public boolean create(Mail_channel mail_channel) {
        boolean bOk = false ;
        Imail_channel clientModel = this.convert2Model(mail_channel,null);
        mail_channelClientService.create(clientModel) ;
        this.convert2Domain(clientModel,mail_channel);
        bOk = true ;

        return bOk ;
    }

    @Override
    public void createBatch(List<Mail_channel> mail_channels, int batchSize) {

                        //mail_channelClientService.createBatch(mail_channels,batchSize) ;

    }

    @Override
    public Mail_channel get(Integer id) {
        Imail_channel clientModel = mail_channelClientService.createModel();
        clientModel.setId(id);
        mail_channelClientService.get(clientModel) ;
        return this.convert2Domain(clientModel,null);
    }

    @Override
    public Mail_channel get(Mail_channel mail_channel) {
        Mail_channel retmail_channel = this.get(mail_channel.getId()) ;
    	BeanCopier copier=BeanCopier.create(retmail_channel.getClass(), mail_channel.getClass(), false);
        copier.copy(retmail_channel, mail_channel, null);
        return mail_channel ;
    }

    @Override
    public void updateBatch(List<Mail_channel> mail_channels, int batchSize) {

        //mail_channelClientService.updateBatch(mail_channels,batchSize) ;

    }

    /**
     * 查询集合 默认查询
     */
    @Override
    public Page<Mail_channel> searchDefault(Mail_channelSearchContext context) {
        List<Mail_channel> list = new ArrayList<Mail_channel>();
        Page<cn.ibizlab.odoo.core.client.model.Imail_channel> clientModelList = mail_channelClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imail_channel clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mail_channel>(list, context.getPageable(), clientModelList.getTotalElements());
    }


    /**
     * 根据即时聊天查询
     */
    @Override
    public Page<Mail_channel> selectByOdoo_livechat_channel(Integer id){
        Mail_channelSearchContext context = new Mail_channelSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mail_channel> list = new ArrayList<Mail_channel>();
        Page<cn.ibizlab.odoo.core.client.model.Imail_channel> clientModelList = mail_channelClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imail_channel clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mail_channel>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据EMail别名查询
     */
    @Override
    public Page<Mail_channel> selectByOdoo_alias(Integer id){
        Mail_channelSearchContext context = new Mail_channelSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mail_channel> list = new ArrayList<Mail_channel>();
        Page<cn.ibizlab.odoo.core.client.model.Imail_channel> clientModelList = mail_channelClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imail_channel clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mail_channel>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据访问群查询
     */
    @Override
    public Page<Mail_channel> selectByOdoo_group_public(Integer id){
        Mail_channelSearchContext context = new Mail_channelSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mail_channel> list = new ArrayList<Mail_channel>();
        Page<cn.ibizlab.odoo.core.client.model.Imail_channel> clientModelList = mail_channelClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imail_channel clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mail_channel>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Mail_channel> selectByOdoo_create(Integer id){
        Mail_channelSearchContext context = new Mail_channelSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mail_channel> list = new ArrayList<Mail_channel>();
        Page<cn.ibizlab.odoo.core.client.model.Imail_channel> clientModelList = mail_channelClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imail_channel clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mail_channel>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Mail_channel> selectByOdoo_write(Integer id){
        Mail_channelSearchContext context = new Mail_channelSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mail_channel> list = new ArrayList<Mail_channel>();
        Page<cn.ibizlab.odoo.core.client.model.Imail_channel> clientModelList = mail_channelClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imail_channel clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mail_channel>(list, context.getPageable(), clientModelList.getTotalElements());

    }



    public Imail_channel convert2Model(Mail_channel domain , Imail_channel model) {
        if(domain == null)
            return model ;
        if(model==null){
            model = mail_channelClientService.createModel() ;
        }

         if(domain.getWebsite_message_idsDirtyFlag())
            model.setWebsite_message_ids(domain.getWebsite_message_ids());
         if(domain.getImage_mediumDirtyFlag())
            model.setImage_medium(domain.getImage_medium());
         if(domain.getModeration_countDirtyFlag())
            model.setModeration_count(domain.getModeration_count());
         if(domain.getDescriptionDirtyFlag())
            model.setDescription(domain.getDescription());
         if(domain.getModeration_notifyDirtyFlag())
            model.setModeration_notify(domain.getModeration_notify());
         if(domain.getMessage_main_attachment_idDirtyFlag())
            model.setMessage_main_attachment_id(domain.getMessage_main_attachment_id());
         if(domain.getModerationDirtyFlag())
            model.setModeration(domain.getModeration());
         if(domain.getIs_moderatorDirtyFlag())
            model.setIs_moderator(domain.getIs_moderator());
         if(domain.getModeration_notify_msgDirtyFlag())
            model.setModeration_notify_msg(domain.getModeration_notify_msg());
         if(domain.getModeration_idsDirtyFlag())
            model.setModeration_ids(domain.getModeration_ids());
         if(domain.getRating_last_imageDirtyFlag())
            model.setRating_last_image(domain.getRating_last_image());
         if(domain.getMessage_has_errorDirtyFlag())
            model.setMessage_has_error(domain.getMessage_has_error());
         if(domain.getModeration_guidelinesDirtyFlag())
            model.setModeration_guidelines(domain.getModeration_guidelines());
         if(domain.getRating_last_feedbackDirtyFlag())
            model.setRating_last_feedback(domain.getRating_last_feedback());
         if(domain.getMessage_idsDirtyFlag())
            model.setMessage_ids(domain.getMessage_ids());
         if(domain.getSubscription_department_idsDirtyFlag())
            model.setSubscription_department_ids(domain.getSubscription_department_ids());
         if(domain.getMessage_unread_counterDirtyFlag())
            model.setMessage_unread_counter(domain.getMessage_unread_counter());
         if(domain.get__last_updateDirtyFlag())
            model.set__last_update(domain.get__last_update());
         if(domain.getIbizpublicDirtyFlag())
            model.setIbizpublic(domain.getIbizpublic());
         if(domain.getMessage_follower_idsDirtyFlag())
            model.setMessage_follower_ids(domain.getMessage_follower_ids());
         if(domain.getMessage_channel_idsDirtyFlag())
            model.setMessage_channel_ids(domain.getMessage_channel_ids());
         if(domain.getRating_idsDirtyFlag())
            model.setRating_ids(domain.getRating_ids());
         if(domain.getAnonymous_nameDirtyFlag())
            model.setAnonymous_name(domain.getAnonymous_name());
         if(domain.getNameDirtyFlag())
            model.setName(domain.getName());
         if(domain.getIs_memberDirtyFlag())
            model.setIs_member(domain.getIs_member());
         if(domain.getIs_subscribedDirtyFlag())
            model.setIs_subscribed(domain.getIs_subscribed());
         if(domain.getModeration_guidelines_msgDirtyFlag())
            model.setModeration_guidelines_msg(domain.getModeration_guidelines_msg());
         if(domain.getMessage_is_followerDirtyFlag())
            model.setMessage_is_follower(domain.getMessage_is_follower());
         if(domain.getIdDirtyFlag())
            model.setId(domain.getId());
         if(domain.getWrite_dateDirtyFlag())
            model.setWrite_date(domain.getWrite_date());
         if(domain.getImageDirtyFlag())
            model.setImage(domain.getImage());
         if(domain.getMessage_attachment_countDirtyFlag())
            model.setMessage_attachment_count(domain.getMessage_attachment_count());
         if(domain.getMessage_unreadDirtyFlag())
            model.setMessage_unread(domain.getMessage_unread());
         if(domain.getCreate_dateDirtyFlag())
            model.setCreate_date(domain.getCreate_date());
         if(domain.getImage_smallDirtyFlag())
            model.setImage_small(domain.getImage_small());
         if(domain.getMessage_partner_idsDirtyFlag())
            model.setMessage_partner_ids(domain.getMessage_partner_ids());
         if(domain.getMessage_has_error_counterDirtyFlag())
            model.setMessage_has_error_counter(domain.getMessage_has_error_counter());
         if(domain.getChannel_partner_idsDirtyFlag())
            model.setChannel_partner_ids(domain.getChannel_partner_ids());
         if(domain.getModerator_idsDirtyFlag())
            model.setModerator_ids(domain.getModerator_ids());
         if(domain.getGroup_idsDirtyFlag())
            model.setGroup_ids(domain.getGroup_ids());
         if(domain.getEmail_sendDirtyFlag())
            model.setEmail_send(domain.getEmail_send());
         if(domain.getChannel_last_seen_partner_idsDirtyFlag())
            model.setChannel_last_seen_partner_ids(domain.getChannel_last_seen_partner_ids());
         if(domain.getMessage_needactionDirtyFlag())
            model.setMessage_needaction(domain.getMessage_needaction());
         if(domain.getUuidDirtyFlag())
            model.setUuid(domain.getUuid());
         if(domain.getRating_countDirtyFlag())
            model.setRating_count(domain.getRating_count());
         if(domain.getDisplay_nameDirtyFlag())
            model.setDisplay_name(domain.getDisplay_name());
         if(domain.getMessage_needaction_counterDirtyFlag())
            model.setMessage_needaction_counter(domain.getMessage_needaction_counter());
         if(domain.getChannel_message_idsDirtyFlag())
            model.setChannel_message_ids(domain.getChannel_message_ids());
         if(domain.getChannel_typeDirtyFlag())
            model.setChannel_type(domain.getChannel_type());
         if(domain.getIs_chatDirtyFlag())
            model.setIs_chat(domain.getIs_chat());
         if(domain.getRating_last_valueDirtyFlag())
            model.setRating_last_value(domain.getRating_last_value());
         if(domain.getAlias_force_thread_idDirtyFlag())
            model.setAlias_force_thread_id(domain.getAlias_force_thread_id());
         if(domain.getAlias_defaultsDirtyFlag())
            model.setAlias_defaults(domain.getAlias_defaults());
         if(domain.getAlias_user_idDirtyFlag())
            model.setAlias_user_id(domain.getAlias_user_id());
         if(domain.getAlias_parent_model_idDirtyFlag())
            model.setAlias_parent_model_id(domain.getAlias_parent_model_id());
         if(domain.getGroup_public_id_textDirtyFlag())
            model.setGroup_public_id_text(domain.getGroup_public_id_text());
         if(domain.getWrite_uid_textDirtyFlag())
            model.setWrite_uid_text(domain.getWrite_uid_text());
         if(domain.getAlias_parent_thread_idDirtyFlag())
            model.setAlias_parent_thread_id(domain.getAlias_parent_thread_id());
         if(domain.getAlias_nameDirtyFlag())
            model.setAlias_name(domain.getAlias_name());
         if(domain.getAlias_model_idDirtyFlag())
            model.setAlias_model_id(domain.getAlias_model_id());
         if(domain.getLivechat_channel_id_textDirtyFlag())
            model.setLivechat_channel_id_text(domain.getLivechat_channel_id_text());
         if(domain.getAlias_domainDirtyFlag())
            model.setAlias_domain(domain.getAlias_domain());
         if(domain.getCreate_uid_textDirtyFlag())
            model.setCreate_uid_text(domain.getCreate_uid_text());
         if(domain.getAlias_contactDirtyFlag())
            model.setAlias_contact(domain.getAlias_contact());
         if(domain.getGroup_public_idDirtyFlag())
            model.setGroup_public_id(domain.getGroup_public_id());
         if(domain.getWrite_uidDirtyFlag())
            model.setWrite_uid(domain.getWrite_uid());
         if(domain.getCreate_uidDirtyFlag())
            model.setCreate_uid(domain.getCreate_uid());
         if(domain.getAlias_idDirtyFlag())
            model.setAlias_id(domain.getAlias_id());
         if(domain.getLivechat_channel_idDirtyFlag())
            model.setLivechat_channel_id(domain.getLivechat_channel_id());
        return model ;
    }

    public Mail_channel convert2Domain( Imail_channel model ,Mail_channel domain) {
        if(model == null)
            return domain ;
        if(domain == null){
            domain = new Mail_channel();
        }

        if(model.getWebsite_message_idsDirtyFlag())
            domain.setWebsite_message_ids(model.getWebsite_message_ids());
        if(model.getImage_mediumDirtyFlag())
            domain.setImage_medium(model.getImage_medium());
        if(model.getModeration_countDirtyFlag())
            domain.setModeration_count(model.getModeration_count());
        if(model.getDescriptionDirtyFlag())
            domain.setDescription(model.getDescription());
        if(model.getModeration_notifyDirtyFlag())
            domain.setModeration_notify(model.getModeration_notify());
        if(model.getMessage_main_attachment_idDirtyFlag())
            domain.setMessage_main_attachment_id(model.getMessage_main_attachment_id());
        if(model.getModerationDirtyFlag())
            domain.setModeration(model.getModeration());
        if(model.getIs_moderatorDirtyFlag())
            domain.setIs_moderator(model.getIs_moderator());
        if(model.getModeration_notify_msgDirtyFlag())
            domain.setModeration_notify_msg(model.getModeration_notify_msg());
        if(model.getModeration_idsDirtyFlag())
            domain.setModeration_ids(model.getModeration_ids());
        if(model.getRating_last_imageDirtyFlag())
            domain.setRating_last_image(model.getRating_last_image());
        if(model.getMessage_has_errorDirtyFlag())
            domain.setMessage_has_error(model.getMessage_has_error());
        if(model.getModeration_guidelinesDirtyFlag())
            domain.setModeration_guidelines(model.getModeration_guidelines());
        if(model.getRating_last_feedbackDirtyFlag())
            domain.setRating_last_feedback(model.getRating_last_feedback());
        if(model.getMessage_idsDirtyFlag())
            domain.setMessage_ids(model.getMessage_ids());
        if(model.getSubscription_department_idsDirtyFlag())
            domain.setSubscription_department_ids(model.getSubscription_department_ids());
        if(model.getMessage_unread_counterDirtyFlag())
            domain.setMessage_unread_counter(model.getMessage_unread_counter());
        if(model.get__last_updateDirtyFlag())
            domain.set__last_update(model.get__last_update());
        if(model.getIbizpublicDirtyFlag())
            domain.setIbizpublic(model.getIbizpublic());
        if(model.getMessage_follower_idsDirtyFlag())
            domain.setMessage_follower_ids(model.getMessage_follower_ids());
        if(model.getMessage_channel_idsDirtyFlag())
            domain.setMessage_channel_ids(model.getMessage_channel_ids());
        if(model.getRating_idsDirtyFlag())
            domain.setRating_ids(model.getRating_ids());
        if(model.getAnonymous_nameDirtyFlag())
            domain.setAnonymous_name(model.getAnonymous_name());
        if(model.getNameDirtyFlag())
            domain.setName(model.getName());
        if(model.getIs_memberDirtyFlag())
            domain.setIs_member(model.getIs_member());
        if(model.getIs_subscribedDirtyFlag())
            domain.setIs_subscribed(model.getIs_subscribed());
        if(model.getModeration_guidelines_msgDirtyFlag())
            domain.setModeration_guidelines_msg(model.getModeration_guidelines_msg());
        if(model.getMessage_is_followerDirtyFlag())
            domain.setMessage_is_follower(model.getMessage_is_follower());
        if(model.getIdDirtyFlag())
            domain.setId(model.getId());
        if(model.getWrite_dateDirtyFlag())
            domain.setWrite_date(model.getWrite_date());
        if(model.getImageDirtyFlag())
            domain.setImage(model.getImage());
        if(model.getMessage_attachment_countDirtyFlag())
            domain.setMessage_attachment_count(model.getMessage_attachment_count());
        if(model.getMessage_unreadDirtyFlag())
            domain.setMessage_unread(model.getMessage_unread());
        if(model.getCreate_dateDirtyFlag())
            domain.setCreate_date(model.getCreate_date());
        if(model.getImage_smallDirtyFlag())
            domain.setImage_small(model.getImage_small());
        if(model.getMessage_partner_idsDirtyFlag())
            domain.setMessage_partner_ids(model.getMessage_partner_ids());
        if(model.getMessage_has_error_counterDirtyFlag())
            domain.setMessage_has_error_counter(model.getMessage_has_error_counter());
        if(model.getChannel_partner_idsDirtyFlag())
            domain.setChannel_partner_ids(model.getChannel_partner_ids());
        if(model.getModerator_idsDirtyFlag())
            domain.setModerator_ids(model.getModerator_ids());
        if(model.getGroup_idsDirtyFlag())
            domain.setGroup_ids(model.getGroup_ids());
        if(model.getEmail_sendDirtyFlag())
            domain.setEmail_send(model.getEmail_send());
        if(model.getChannel_last_seen_partner_idsDirtyFlag())
            domain.setChannel_last_seen_partner_ids(model.getChannel_last_seen_partner_ids());
        if(model.getMessage_needactionDirtyFlag())
            domain.setMessage_needaction(model.getMessage_needaction());
        if(model.getUuidDirtyFlag())
            domain.setUuid(model.getUuid());
        if(model.getRating_countDirtyFlag())
            domain.setRating_count(model.getRating_count());
        if(model.getDisplay_nameDirtyFlag())
            domain.setDisplay_name(model.getDisplay_name());
        if(model.getMessage_needaction_counterDirtyFlag())
            domain.setMessage_needaction_counter(model.getMessage_needaction_counter());
        if(model.getChannel_message_idsDirtyFlag())
            domain.setChannel_message_ids(model.getChannel_message_ids());
        if(model.getChannel_typeDirtyFlag())
            domain.setChannel_type(model.getChannel_type());
        if(model.getIs_chatDirtyFlag())
            domain.setIs_chat(model.getIs_chat());
        if(model.getRating_last_valueDirtyFlag())
            domain.setRating_last_value(model.getRating_last_value());
        if(model.getAlias_force_thread_idDirtyFlag())
            domain.setAlias_force_thread_id(model.getAlias_force_thread_id());
        if(model.getAlias_defaultsDirtyFlag())
            domain.setAlias_defaults(model.getAlias_defaults());
        if(model.getAlias_user_idDirtyFlag())
            domain.setAlias_user_id(model.getAlias_user_id());
        if(model.getAlias_parent_model_idDirtyFlag())
            domain.setAlias_parent_model_id(model.getAlias_parent_model_id());
        if(model.getGroup_public_id_textDirtyFlag())
            domain.setGroup_public_id_text(model.getGroup_public_id_text());
        if(model.getWrite_uid_textDirtyFlag())
            domain.setWrite_uid_text(model.getWrite_uid_text());
        if(model.getAlias_parent_thread_idDirtyFlag())
            domain.setAlias_parent_thread_id(model.getAlias_parent_thread_id());
        if(model.getAlias_nameDirtyFlag())
            domain.setAlias_name(model.getAlias_name());
        if(model.getAlias_model_idDirtyFlag())
            domain.setAlias_model_id(model.getAlias_model_id());
        if(model.getLivechat_channel_id_textDirtyFlag())
            domain.setLivechat_channel_id_text(model.getLivechat_channel_id_text());
        if(model.getAlias_domainDirtyFlag())
            domain.setAlias_domain(model.getAlias_domain());
        if(model.getCreate_uid_textDirtyFlag())
            domain.setCreate_uid_text(model.getCreate_uid_text());
        if(model.getAlias_contactDirtyFlag())
            domain.setAlias_contact(model.getAlias_contact());
        if(model.getGroup_public_idDirtyFlag())
            domain.setGroup_public_id(model.getGroup_public_id());
        if(model.getWrite_uidDirtyFlag())
            domain.setWrite_uid(model.getWrite_uid());
        if(model.getCreate_uidDirtyFlag())
            domain.setCreate_uid(model.getCreate_uid());
        if(model.getAlias_idDirtyFlag())
            domain.setAlias_id(model.getAlias_id());
        if(model.getLivechat_channel_idDirtyFlag())
            domain.setLivechat_channel_id(model.getLivechat_channel_id());
        return domain ;
    }


}
